//
//  DeviceBindGuideVC.m
//  xychain_DM_iOS
//
//  Created by Jpwang on 2018/5/26.
//  Copyright © 2018年 Jpwang. All rights reserved.
//

#import "DeviceBindGuideVC.h"
#import "DeviceBindVC.h"

@interface DeviceBindGuideVC () {
    BOOL isFromLoadingVC;
    BOOL isHiddenNextBt;
}

@property(weak, nonatomic) IBOutlet UIButton *nextBt;

@end

@implementation DeviceBindGuideVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setIsFromLoadingVC:(BOOL) isFrom {
    isFromLoadingVC = isFrom;
}

- (void)setHiddenNextBt:(BOOL)hidden {
    isHiddenNextBt = YES;
}

- (void)initView {
    // 顶部title
    CGSize size = [[UIApplication sharedApplication] statusBarFrame].size;
    UIView *topBar = [[UIView alloc] initWithFrame:CGRectMake(0, size.height, size.width, 44)];
    topBar.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.0f];
    [self.view addSubview:topBar];
    float height = 25;
    UIButton *bt = [[UIButton alloc] initWithFrame:CGRectMake(16, 22-height/2, height, height)];
    [bt setBackgroundImage:[UIImage imageNamed:@"img_close_xb"] forState:UIControlStateNormal];
    [[bt rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        [self.navigationController popViewControllerAnimated:YES];
    }];
    [topBar addSubview:bt];
    [[self.nextBt rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        DeviceBindVC *vc = [storyboard instantiateViewControllerWithIdentifier:@"DeviceBindVCID"];
        [vc setIsFromLoadingVC:self->isFromLoadingVC];
        [self.navigationController pushViewController:vc animated:NO];
    }];
    [self.nextBt setHidden:isHiddenNextBt];
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleDefault;
}

@end
